<?php
namespace haibao\cms\data\attendance;


class AttendanceRequest extends \haibao\cms\data\BaseMysql{
	
	public function __construct(){
		parent::__construct('\haibao\cms\model\data\attendance\AttendanceRequest');
	}
	
	public function checkRequestOverTimeIsExist($requestModel){
		
		$sql = 'select count(*) as cnt from AttendanceRequest where JobNum=%s and StartDate=%s and RequestType=%s and RequestStatus !=%s';
		$result = $this->query($sql,array($requestModel->JobNum,$requestModel->StartDate,\haibao\cms\model\data\attendance\AttendanceRequest::TYPE_OVERTIME,\haibao\cms\model\data\attendance\AttendanceRequest::STATUS_BACK))->fetch_assoc();
		return $result['cnt'];
	}
	
	public function getNotApprovedUser($startDate,$endDate){
		$userIdArr = array();
		$sql = 'SELECT Id,JobNum,AuditUserId FROM `AttendanceRequest` WHERE StartDate>=%s AND StartDate<=%s AND RequestStatus IN (0,3)';
		$result = $this->query($sql,array($startDate,$endDate));
		while ($result->fetch_assoc()){
			array_push($userIdArr, $result->getData('AuditUserId'));
		}
		return $userIdArr;
	}
}